package com.wangzh.controller;


import com.wangzh.controller.util.R;
import com.wangzh.dao.SMSCode;
import com.wangzh.service.ISMSCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sms")
public class SMSCodeController {

    @Autowired
    private ISMSCode ismsCode;

    @GetMapping
    public R getCode(String tele){
        String s = ismsCode.sendCodeToSMS(tele);
        return new R(true,s);
    }

    @PostMapping
    public R checkCode(SMSCode smsCode){
        boolean b = ismsCode.checkCode(smsCode);
        return new R(b);

    }
}
